package com.jdew.thkj.activity;

import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jdew.thkj.R;
import com.jdew.thkj.base.BaseActivity;

import butterknife.Bind;

/**
 * Created by yangzai on 2018/8/7.
 */

public class NewGuideActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.back)
    ImageView back;
    @Bind(R.id.title)
    TextView title;
    @Bind(R.id.play)
    LinearLayout play;
    private String url = "http://www.taohuikeji.com/Attachment/xszd1.mp4";
    private String extension;
    private String mimeType;

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back: {
                finish();
            }
            break;
            case R.id.play: {
                extension = MimeTypeMap.getFileExtensionFromUrl(url);
                mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
                Intent mediaIntent = new Intent(Intent.ACTION_VIEW);
                mediaIntent.setDataAndType(Uri.parse(url), mimeType);
                startActivity(mediaIntent);
            }
            break;
            default:
                break;
        }
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_new_guide;
    }

    @Override
    public void initView(View view) {
        title.setText("新手指导");
        back.setVisibility(View.VISIBLE);
        back.setOnClickListener(this);
        play.setOnClickListener(this);
    }

}
